# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Union
from decimal import Decimal
from fastapi import Query
from pydantic import BaseModel, Field


class RechargePackageDetailIn(BaseModel):
    """ 充值套餐详情参数 """
    id: int = Query(..., gt=0, description="套餐ID")


class RechargePackageAddIn(BaseModel):
    """ 充值套餐新增参数 """
    name: str = Field(..., min_length=1, max_length=100, description="套餐名称")
    tags: str = Field(default="", max_length=100, description="套餐标签")
    sell_price: Decimal = Field(..., max_digits=10, decimal_places=2, description="销售价格")
    line_price: Decimal = Field(..., max_digits=10, decimal_places=2, description="划线价格")
    points_num: Union[int, None] = Field(default=0, description="积分数量")
    train_num: Union[int, None] = Field(default=0, description="训练组数量")
    robot_num: Union[int, None] = Field(default=0, description="智能体数量")
    know_num: Union[int, None] = Field(default=0, description="知识库数量")
    mcp_num: Union[int, None] = Field(default=0, description="MCP数量")
    sort: int = Field(default=0, ge=0, description="排序编号")
    is_disable: int = Field(default=0, ge=0, le=1, description="是否禁用: [0=否, 1=是]")

    @classmethod
    def messages(cls):
        return {
            "name.min_length": "请填写套餐名称",
            "name.max_length": "套餐名称不能超出100个字符",
            "tags.max_length": "套餐标签不能超出100个字符",
            "sell_price.missing": "请填写销售价格",
            "sell_price.max_digits": "销售价格整数部分不能超出8位",
            "sell_price.decimal_places": "销售价格只能保留2位小数",
            "line_price.missing": "请填写划线价格",
            "line_price.max_digits": "划线价格整数部分不能超出8位",
            "line_price.decimal_places": "划线价格只能保留2位小数",
            "sort.ge": "排序号不能少于0",
            "is_disable.ge": "状态非合法值: [0, 1]",
            "is_disable.le": "状态非合法值: [0, 1]"
        }

    class Config:
        json_schema_extra = {
            "example": {
                "name": "尊享套餐",
                "tags": "限时特惠",
                "sell_price": 10.88,
                "line_price": 20.98,
                "points_num": 100,
                "train_num": 20,
                "robot_num": 20,
                "know_num": 20,
                "mcp_num": 20,
                "sort": 10,
                "is_disable": 0
            }
        }


class RechargePackageEditIn(BaseModel):
    """ 充值套餐编辑参数 """
    id: int = Field(..., gt=0, description="套餐ID")
    name: str = Field(..., min_length=1, max_length=100, description="套餐名称")
    tags: str = Field(default="", max_length=100, description="套餐标签")
    sell_price: Decimal = Field(..., max_digits=10, decimal_places=2, description="销售价格")
    line_price: Decimal = Field(..., max_digits=10, decimal_places=2, description="划线价格")
    points_num: Union[int, None] = Field(default=0, description="积分数量")
    train_num: Union[int, None] = Field(default=0, description="训练组数量")
    robot_num: Union[int, None] = Field(default=0, description="智能体数量")
    know_num: Union[int, None] = Field(default=0, description="知识库数量")
    mcp_num: Union[int, None] = Field(default=0, description="MCP数量")
    sort: int = Field(default=0, ge=0, description="排序编号")
    is_disable: int = Field(default=0, ge=0, le=1, description="是否显示: [0=否, 1=是]")

    @classmethod
    def messages(cls):
        return RechargePackageAddIn.messages()

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "name": "尊享套餐",
                "tags": "限时特惠",
                "sell_price": 10.88,
                "line_price": 20.98,
                "points_num": 100,
                "train_num": 20,
                "robot_num": 20,
                "know_num": 20,
                "mcp_num": 20,
                "sort": 10,
                "is_disable": 0
            }
        }


class RechargePackageDeleteIn(BaseModel):
    """ 充值套餐删除参数 """
    id: int = Field(gt=0, description="套餐ID", examples=[1])

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1
            }
        }


class RechargeConfigIn(BaseModel):
    """ 充值套餐配置参数 """
    status: int = Field(ge=0, le=1, description="充值状态", examples=[1])

    class Config:
        json_schema_extra = {
            "example": {
                "status": 1
            }
        }


"""--------------- Separator ---------------"""


class RechargePackageListVo(BaseModel):
    """ 充值套餐列表Vo """
    id: int = Field(description="套餐ID")
    name: str = Field(description="套餐名称")
    sell_price: Decimal = Field(description="销售价格")
    line_price: Decimal = Field(description="划线价格")
    points_num: int = Field(description="积分数量")
    train_num: int = Field(description="训练组数量")
    robot_num: int = Field(description="智能体数量")
    know_num: int = Field(description="知识库数量")
    mcp_num: int = Field(description="MCP数量")
    sort: int = Field(description="排序编号")
    is_disable: int = Field(description="是否禁用: [0=否, 1=是]")
    create_time: str = Field(description="创建时间")
    update_time: str = Field(description="更新时间")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "name": "尊享套餐",
                "sell_price": 10.88,
                "line_price": 20.98,
                "points_num": 100,
                "train_num": 20,
                "robot_num": 20,
                "know_num": 20,
                "mcp_num": 20,
                "sort": 10,
                "is_disable": 0,
                "create_time": "2023-07-22 11:33:44",
                "update_time": "2023-07-22 11:33:44"
            }
        }


class RechargePackageDetailVo(BaseModel):
    """ 充值套餐详情Vo """
    id: int = Field(description="套餐ID")
    name: str = Field(description="套餐名称")
    tags: str = Field(description="套餐标签")
    sell_price: Decimal = Field(description="销售价格")
    line_price: Decimal = Field(description="划线价格")
    points_num: int = Field(description="积分数量")
    train_num: int = Field(description="训练组数量")
    robot_num: int = Field(description="智能体数量")
    know_num: int = Field(description="知识库数量")
    mcp_num: int = Field(description="MCP数量")
    sort: int = Field(description="排序编号")
    is_disable: int = Field(description="是否禁用: [0=否, 1=是]")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "name": "尊享套餐",
                "tags": "限时折扣",
                "sell_price": 10.88,
                "line_price": 20.98,
                "points_num": 100,
                "train_num": 20,
                "robot_num": 20,
                "know_num": 20,
                "mcp_num": 20,
                "sort": 10,
                "is_disable": 0
            }
        }
